#include "stdafx.h"
#include "ckCheckResult.h"
#include "ckCheckResultItem.h"

namespace ck
{
	namespace check
	{
		CheckResult::CheckResult()
		{
		}


		CheckResult::~CheckResult()
		{
			CheckResultItem *pItem = NULL;
			std::vector<CheckResultItem*>::iterator iter;
			for (iter = m_items.begin(); iter != m_items.end(); iter++)
			{
				pItem = *iter;
				if (pItem)
				{
					pItem->Release();
				}
			}
			m_items.clear();
		}

		RESULTCODE CheckResult::AddItem(CheckResultItem* pItem)
		{
			if (!pItem)
			{
				return RC_FAILURE;
			}

			m_items.push_back(pItem);

			return RC_SUCCESS;
		}

		z_uint32 CheckResult::GetCount()
		{
			return m_items.size();
		}

		CheckResultItem* CheckResult::GetItem(z_uint32 i)
		{
			if (i >= m_items.size())
			{
				return NULL;
			}

			return m_items[i];
		}

		void CheckResult::SetOperator(const char* szName)
		{
			if (szName)
			{
				m_strOperName = szName;
			}
		}

		const char*	CheckResult::GetOperator()
		{
			return m_strOperName.c_str();
		}
	}
}
